package cn.ctbu.xiaopeng.studentscoremanage.service;

import cn.ctbu.xiaopeng.studentscoremanage.anno.Log;
import cn.ctbu.xiaopeng.studentscoremanage.dao.DepartmentRepository;
import cn.ctbu.xiaopeng.studentscoremanage.pojo.vo.DepartmentListVO;
import cn.hutool.core.bean.BeanUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiaopeng
 * @version 1.0
 */
@Service
@RequiredArgsConstructor
public class DepartmentService {

    private final DepartmentRepository departmentRepository;

    @Log
    public List<DepartmentListVO> findAll() {
        return BeanUtil.copyToList(departmentRepository.findAll(), DepartmentListVO.class);
    }

    /**
     * 根据部门编号获取部门名称
     *
     * @param departmentId
     * @return
     */
    @Log
    public String getDepartmentNameById(String departmentId) {
        return departmentRepository.findDepartmentByDepartmentId(departmentId).getDepartment();
    }
}
